<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>{{ title }}</title>
</head>
<body>
你的ip是：{{ ip }}
<label for="input">
    <input type="text" id="input">
    <input value="send" type="button" id="send" onclick="send()">
</label>
<script>
    var url = 'ws://127.0.0.1:8000'
    var ws = new WebSocket(url)
    ws.onopen = function(e) {
        console.log('onopen', e)
    }
    ws.onclose = function(e) {
        console.log('onclose', e)
    }
    ws.onerror = function(e) {
        console.log('onerror', e)
    }
    ws.onmessage = function(e) {
        console.log('onmessage', e.data)
    }
    function send() {
        var val = document.getElementById('input').value
        ws.send(val)
    }
</script>
</body>
</html>